package com.cll.controller.user;


import com.cll.constant.StatusConstant;
import com.cll.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "用户店铺相关接口")
@RestController("userShopController")
@Slf4j
@RequestMapping("/user/shop")
public class ShopController {

    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private static final String KEY = "SHOP_STATUS";

    @ApiOperation("用户获取店铺状态")
    @GetMapping("status")
    public Result getStatus(){
        //在redis缓存中获取KEY
        Integer status = (Integer) redisTemplate.opsForValue().get(KEY);
        log.info("用户获取店铺状态: " + (StatusConstant.ENABLE.equals(status)?"营业中":"已打烊"));
        return Result.success(status);
    }

}
